﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace MementoClientConnectorLibrary
{
    public class TfsClientConnectorConfigSection : ConfigurationSection
    {
        [ConfigurationProperty("systems")]
        public TfsClientConnectorSystemCollection TfsSystems 
        {
            get { return (TfsClientConnectorSystemCollection)this["systems"]; }
        }
    }

    public class TfsClientConnectorSystem : ConfigurationElement
    {
        [ConfigurationProperty("uniqueID", IsRequired = true)]
        public string UniqueID 
        {
            get { return this["uniqueID"] as string; }
        }
        [ConfigurationProperty("tfsServerUrl", IsRequired = true)]
        public string TfsServerUrl 
        { 
            get { return this["tfsServerUrl"] as string; }
        }
    }

    public class TfsClientConnectorSystemCollection : ConfigurationElementCollection
    {
        public TfsClientConnectorSystem this[int index]
        {
            get
            {
                return BaseGet(index) as TfsClientConnectorSystem;
            }
        }
        protected override ConfigurationElement CreateNewElement()
        {
            return new TfsClientConnectorSystem();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return (element as TfsClientConnectorSystem).UniqueID;
        }
    }
}
